package com.evan.common.controller;

import com.evan.common.bit.RoleType;
import com.evan.common.pojo.Roles;
import com.evan.common.pojo.User;
import com.evan.common.service.UserService;
import com.evan.common.service.impl.UserServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.management.relation.Role;
import java.util.List;

/**
 * @description:
 * @author: xiaohu
 * @createDate: 2021/7/14 23:28
 */
@RestController
@RequestMapping("/user")
@Api("User -- 用户接口")
public class UserController {
    @Qualifier("service")
    @Autowired
    UserService us = new UserServiceImpl();

    @GetMapping("/all")
    @ApiOperation("获取所有用户")
    public List<User> getAllUser(){
        return  us.getAllUser();
    }

    @PostMapping("/add")
    @ApiOperation("添加用户")
    public List<User> addUser(User user){
        us.addUser(user);
        return us.getAllUser();
    }
}
